/*
 * CharClassify.h
 *
 *  Created on: 2011-5-28
 *      Author: yangentao
 */

#ifndef CHARCLASSIFY_H_
#define CHARCLASSIFY_H_

class CharClassify {
public:
	CharClassify();
	virtual ~CharClassify();

	enum cc { ccSpace, ccNewLine, ccWord, ccPunctuation };
	void SetDefaultCharClasses(bool includeWordClass);
	void SetCharClasses(const unsigned char *chars, cc newCharClass);
	cc GetClass(unsigned char ch) const { return static_cast<cc>(charClass[ch]);}
	bool IsWord(unsigned char ch) const { return static_cast<cc>(charClass[ch]) == ccWord;}

private:
	enum { maxChar=256 };
	unsigned char charClass[maxChar];    // not type cc to save space
};

#endif /* CHARCLASSIFY_H_ */
